package com.magoldeditor.view;

import java.awt.Color;
import java.util.HashMap;
import java.util.Iterator;

import javax.swing.JTextField;

import com.magoldeditor.controller.MaEditorMouseListener;
import com.magoldeditor.controller.MaEditorMouseMotionListener;
import com.magoldeditor.model.IPainter;
import com.magoldeditor.model.entity.IEntityConstructor;

/**
 * 
 * @author Velconia
 *
 * @version v.1.0
 * 
 */
public class ShowPanel extends MaEditorPanel implements IEntityConstructor {
	
	/**
	 * serial version UID
	 */
	private static final long serialVersionUID = 7L;

	/**
	 * 
	 */
	public ShowPanel(){
		super(null, null, null, null);
	}
	
	/**
	 * 
	 * @param name
	 */
	public ShowPanel(String name) {
		super(null, null, null, name);
	}
	
	/**
	 * 
	 * @param color
	 * @param name
	 */
	public ShowPanel(Color color, String name) {
		super(color, null, null, name);
	}
	
	/**
	 * 
	 * @param color
	 * @param mouseMotionListener
	 * @param mouseListener
	 * @param name
	 */
	public ShowPanel(Color color, MaEditorMouseMotionListener mouseMotionListener, MaEditorMouseListener mouseListener, String name) {
		super(color, mouseMotionListener, mouseListener, name);
	}
	
	@Override
	public void setMouseListener(MaEditorMouseListener mouseListener) {
		super.setMouseListener(mouseListener);
	}
	
	@Override
	public void edit(IPainter[] p) {
		if (p != null) {
			int len = p.length - 1;
			
			for (int i = 0; i < len - 1; i++) {
				if (p[i].isEnable()) {
					p[i].setEnable(false);
				}
			}
		}
	}
	
	@Override
	public HashMap<String, String> construct(HashMap<String, String> pair) {
		Iterator<String> iterator = pair.values().iterator();
		while(iterator.hasNext()) {
			this.add(new JTextField(iterator.next()));
		}
		return null;
	}
}